package com.oasystem.service;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.oasystem.dao.jdbc.GoodsDAO;
import com.oasystem.domain.Goods;
import com.oasystem.domain.PagingBean;

@Transactional(readOnly = true)
public class GoodsService {
	private GoodsDAO goodsDAO;

	public void setGoodsDAO(GoodsDAO goodsDAO) {
		this.goodsDAO = goodsDAO;
	}

	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor = { Exception.class })
	public void insertGoods(Goods goods) {
		goodsDAO.insertGoods(goods);
	}
	
	public boolean isGoodsNameNotExist(String name) {
		return goodsDAO.isGoodsNameNotExist(name);
	}
	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor = { Exception.class })
	public void updateOperator(Goods goods) {
		goodsDAO.updateGoods(goods);
	}

	public void getPagingGoods(PagingBean<Goods> pagingBean) {
		goodsDAO.getPagingGoods(pagingBean);
	}
	
	public List<Goods> getAllGoods() {
		return goodsDAO.getAllGoods();
	}

	public void loadGoods(Goods goods) {
		goodsDAO.load(goods);
	}

	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor = { Exception.class })
	public void deleteGoods(Goods goods) {
		goodsDAO.deleteGoods(goods);
	}
}
